from rest_framework.views import APIView
from .serializers import SKUListSerializers
from rest_framework.generics import ListAPIView
from orders.models import OrderGoods
from rest_framework.response import Response
import time
import datetime
from rest_framework.decorators import action
class SKUComments(ListAPIView):
    """
    商品评论
    """
    serializer_class = SKUListSerializers

    def get_queryset(self):
        sku_id = self.kwargs['sku_id']
        return OrderGoods.objects.filter(sku_id=sku_id)


class SKUSecondKill(APIView):
    """
    秒杀倒计时
    """
    def get(self,request):
        t = time.time()
        a = 1554970035
        # c = int(t) + 3600
        time_second = a - int(t)

        # times = time.strftime("%H:%M:%S", time.localtime(d))
        return Response(data=time_second)